<!DOCTYPE html>
<html lang="en-US">
  <head>
    <link href="/assets/index.css" rel="stylesheet" type="text/css" />
    <script crossorigin="anonymous" src="/test-harness.js"></script>
    <script crossorigin="anonymous" src="/test-page-object.js"></script>
    <script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script>
  </head>
  <body>
    <main id="webchat"></main>
    <script>
      run(async function () {
        const store = testHelpers.createStore({}, ({ dispatch }) => next => action => {
          if (action.type === 'DIRECT_LINE/CONNECT_FULFILLED') {
            dispatch({
              type: 'WEB_CHAT/SET_NOTIFICATION',
              payload: {
                id: 'privacypolicy',
                level: 'info',
                message: 'Please read our privacy policy.'
              }
            });
          }

          return next(action);
        });

        WebChat.renderWebChat(
          {
            directLine: WebChat.createDirectLine({
              token: await testHelpers.token.fetchDirectLineToken()
            }),
            store
          },
          document.getElementById('webchat')
        );

        await pageConditions.uiConnected();
        await pageConditions.toastShown(/privacy\spolicy/iu);
        await host.snapshot('local');
      });
    </script>
  </body>
</html>
